import HTTP from '../../../../utils/http.js';
import { API, API_GENERATE } from '../../../../config/api.js';

let DETAILS = {
	P: {
		slow: API.ORDER_DETAILS_SLOW_BUY,
		slowList: API.ORDER_DETAILS_SLOW_LIST_BUY,
		jsList: API.ORDER_DETAILS_JS_LIST_BUY,
		jsDetail: API.ORDER_DETAILS_JS_DETAIL_BUY,
		fpPool: API.ORDER_DETAILS_FP_BUY,
		stockPool: API.ORDER_DETAILS_STOCK_BUY,
		stockList: API.ORDER_DETAILS_STOCK_LIST_BUY,
		stockMxList: API.ORDER_DETAILS_STOCK_LIST_MX_BUY,
		stockMxDetial: API.ORDER_DETAILS_STOCK_DETAIL_MX_BUY,
		stockWlList: API.ORDER_DETAILS_STOCK_LIST_WL,
		stockWlDetial: API.ORDER_DETAILS_STOCK_DETAIL_WL,
		stockWlDd: API.ORDER_DETAILS_STOCK_DETAIL_WL_DD,
		stockWlDdImg: API.ORDER_DETAILS_STOCK_DETAIL_WL_IMG,
		stockRk: API.ORDER_DETAILS_STOCK_DETAIL_CK_BUY,
	},
	S: {
		slow: API.ORDER_DETAILS_SLOW_SELL,
		slowList: API.ORDER_DETAILS_SLOW_LIST_SELL,
		jsList: API.ORDER_DETAILS_JS_LIST_SELL,
		jsDetail: API.ORDER_DETAILS_JS_DETAIL_SELL,
		fpPool: API.ORDER_DETAILS_FP_SELL,
		stockPool: API.ORDER_DETAILS_STOCK_SELL,
		stockList: API.ORDER_DETAILS_STOCK_LIST_SELL,
		stockMxList: API.ORDER_DETAILS_STOCK_LIST_MX_SELL,
		stockMxDetial: API.ORDER_DETAILS_STOCK_DETAIL_MX_SELL,
		stockWlList: API.ORDER_DETAILS_STOCK_LIST_WL,
		stockWlDetial: API.ORDER_DETAILS_STOCK_DETAIL_WL,
		stockWlDd: API.ORDER_DETAILS_STOCK_DETAIL_WL_DD,
		stockWlDdImg: API.ORDER_DETAILS_STOCK_DETAIL_WL_IMG,
		stockRk: API.ORDER_DETAILS_STOCK_DETAIL_CK_SELL
	}
}

class OrderDetailsService {
	initAPI (orderType) {
		this.url = DETAILS[orderType];
	}
	//敞口详情
	baseIndoDetail (params = {}) {
		let url = API.ORDER_DETAILS_BASE + params;
		return HTTP.POST(API_GENERATE(url));
	}
	//撤销订单
	cancelOrder (params = {}) {
		return HTTP.POST(API_GENERATE(API.ORDER_REVOKE), params);
	}
	//作废订单
	verbOrder (params = {}) {
		return HTTP.POST(API_GENERATE(API.QH_ORDER_OBSOLETE), params);
	}
	//删除订单
	removeOrder (params = {}) {
		return HTTP.POST(API_GENERATE(API.ORDER_DELETE), params);
	}
	// 付款/收款 汇总
	slowPool (params = {}) {
		return HTTP.POST(API_GENERATE(this.url.slow), params);
	}
	// 付款/收款 列表
	slowListDetail (params = {}) {
		return HTTP.POST(API_GENERATE(this.url.slowList), params);
	}
	//结算 汇总
	jsPool (params = {}) {
		return HTTP.POST(API_GENERATE(this.url.jsPool), params);
	}
	//结算 列表
	jsList (params = {}) {
		return HTTP.POST(API_GENERATE(this.url.jsList), params);
	}
	//结算 详情
	jsDetail (params = {}) {
		return HTTP.POST(API_GENERATE(this.url.jsDetail), params);
	}
	//发票 汇总
	fpPool (params = {}) {
		return HTTP.POST(API_GENERATE(this.url.fpPool), params);
	}
	//仓库 汇总
	stockPool (params = {}) {
		return HTTP.POST(API_GENERATE(this.url.stockPool), params);
	}
	//仓库 通知单 列表
	stockList (params = {}) {
		return HTTP.POST(API_GENERATE(this.url.stockList), params);
	}
	//仓库 通知单 详情
	stockRk (params = {}) {
		return HTTP.POST(API_GENERATE(this.url.stockRk), params);
	}
	//仓库 收发明细 列表
	stockMxList (params = {}) {
		return HTTP.POST(API_GENERATE(this.url.stockMxList), params);
	}
	//仓库 收发明细 详情
	stockMxDetail (params = {}) {
		return HTTP.POST(API_GENERATE(this.url.stockMxDetial), params);
	}
	//仓库 物流 列表
	stockWlList (params = {}) {
		return HTTP.POST(API_GENERATE(this.url.stockWlList), params);
	}
	//仓库 物流 详情
	stockWlDetail (params = {}) {
		return HTTP.POST(API_GENERATE(this.url.stockWlDetial), params);
	}
	//仓库 物流 调度
	stockWlDd (params = {}) {
		return HTTP.POST(API_GENERATE(this.url.stockWlDd), params);
	}
	//仓库 物流 调度 获取图片
	stockWlDdImg (params, extName) {
		let url = this.url.stockWlDdImg + `?urlstr=${params}&extName=${extName}`;
		return HTTP.GET(API_GENERATE(url));
	}
	//审批流程查看
	approval (orderId, lsId, corpId) {
		return HTTP.GET(API_GENERATE(API.ORDER_AUDITLIST) + '?bizId=' + orderId + '&processInstanceId=' + (lsId || null) + '&corpId=' + (corpId || null));
	}
	//审批业务流程查看
	checkApproval (orderId, bizObjType, lsId, corpId) {
		return HTTP.GET(API_GENERATE(API.APPROVAL_NODE) + '?bizId=' + orderId + '&bizObjType=' + bizObjType + '&processInstanceId=' + lsId + '&corpId=' + (corpId || null));
	}
	// 经营计划审批流查看
	checkApprovalFlow (orderId, bizObjType, processInstanceId, corpId) {
		return HTTP.GET(API_GENERATE(API.PLAN_AUDITLIST) + '?bizId=' + orderId + '&bizObjType=' + bizObjType + '&processInstanceId=' + processInstanceId + '&corpId=' + (corpId || null));
	}
}
module.exports = new OrderDetailsService();